home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
bathints.zip
/
BH_11.DOC
< prev
next >
Wrap
Text File
|
1988-11-03
|
11KB
|
214 lines
BAT-HINT # 11
**************************************************************************
from the BATHINTS library... part of the BATPOWER CONFERENCE from:
THE PAINFRAME OPUS/FIDO 261/1004
Baltimore, Maryland 1-301-488-7461
**************************************************************************
COMMAND.COM ...The Final Treatise?
Command.com is an executable program just like all other .com
files in DOS. Running the "command" command invokes a secondary command
processor, using up about 2 to 4 Kbytes of RAM, depending on the
version of DOS that you employ. There are several optional command.com
parameters in DOS 3.x:
/p will permanently (until reboot) load the secondary command
processor
/c allows you to pass a string to the secondary command
processor
/e sets the environment size
/f nullifys the ABORT, RETRY, FAIL statement
/d disables execution of autoexec.bat
Not all of these optional parameters are used on the command line
itself and only the /c parameter is used extensively. I addition, you
should be aware that many third-party DOSs may use these parameters in
different ways and may also offer other parameters to control the
behaviour of command.com.
The /p parameter finds its greatest use when employed in the
config.sys file to expand the environment. For example:
shell=command.com /e:62 /p [DOS 3.1] or
shell=command.com /e:32768 /p [DOS 3.2 & 3.3]
will expand the environment to the maximum 992 bytes allowable in DOS
3.1 (62 x 16 = 992) or 32768 bytes in DOS 3.2 or 3.3. This is very
useful when long paths, many environmental variables or programs
employing user defined environmental variables are used. The value
used in DOS 3.1 is specified in increments of 16 bytes and defaults to
a value of 10 (160 bytes) if the /e parameter is omitted. The same 160
byte default value is used in higher versions of DOS, but the value
entered is in bytes rather than in 10 byte increments. Setting a value
for the /e parameter below 160 is ignored by DOS 3.2 or 3.3 and is
reset to 160.
When command.com is run without any parameters, the new command
processor embraces the environment of the previous command processor.
So expanding the environment by issuing one of the config.sys commands
shown above will also result in an expanded environment in any
subsequent command processor. Although any environmental variables
defined in the primary command processor's environment (i.e. path,
prompt, etc.) will be retained in the secondary command processor's
environment, the size of this environment will be limited to that
required to embrace the previously defined variables and fill out that
paragraph of memory, depending on the version of DOS employed and the
manner in which the "set" command is issued for defining new variables
in the secondary command processor's environment. In DOS 3.1 the
increased environment size is lost beyond that required to retain those
variables that have been defined, but in higher versions of DOS the
size of the expanded environment is retained for the definition of
variables using the "set" command from the command line... but not from
within batch files. One further point is that in the higher versions
of DOS the /e parameter can be used when the secondary command
processor is invoked, allowing for even greater control over the size
of the seconadary command processor's environment.
In all DOS 3.x versions, any variables defined in the secondary
command processor's environment are lost when the "exit" command is
issued to return to the primary command processor. This latter point
is usefull for quickly and temporarily changing the value of the path
variable for special applications or purposes, since upon returning to
the primary command processor the original value of the variable is
restored. Thus, if you normally employ a long path but occasionally
want to modify the path for a special application, you need only enter
command
set path=[your new path]
to invoke a new path in the secondary command processor. All other
environmental variables will remain the same. To return to the original
command processor, just type
exit
at the DOS prompt. Your original path will be intact.
Their are several methods of calling a batch file from within a
running batch file. Simply naming the batch file to be executed (and
the drive and subdirectory location of the batch file if the location
of that batch file is not included in the path variable), will
successfully execute the second batch file. This method however, will
result in the termination of the first batch file since processing is
not returned to the original batch file when a second batch file is
called. Nonetheless, this is a usefull way of chaining batch files
when a return to the original batch file is unwanted, such as in the
case where a user selection is made that causes the first batch file to
"goto" a line that executes another batch file.
The command /c command is used for calling a batch file from
another batch file when one desires that the commands in the first
batch file be completed. To call another batch file from within a
batch file in DOS 3.1 enter the following line in the first batch file:
command /c batname
BATNAME.bat will be executed and will return to the next line in the
original bat file. Alternatively, you could enter
command batname
Again, BATNAME will be executed... but this time reentry into the first
bat file is accomplished with the EXIT command. The EXIT command could
be placed at the end of the second bat file or at some other location
in the second bat file executable upon a conditional statement.
In DOS versions higher than 3.1, the command /c command for
calling a batch file from within a batch file can be replaced with the
DOS internal command "call". The call command performs essentially the
same task as the command /c command but does not invoke a secondary
command processor and thus saves you the memory required by the
previous method. To call a second batch file and return to the intila
batch file using the "call" command, you could enter:
call batname
As described above for the command command, BATNAME will be executed...
with no need for an exit command since a secondary command processor
was not invoked.
Very few files, including command.com, need be present in the root
directory of your hard disk or floppy boot disk. Indeed, the only
files in the root should be config.sys and autoexec.bat (if you choose
to even have an autoexec.bat). Be carefull of programs that absolutely
demand that command.com be in the root dir of the boot disk, however.
So how does one place command.com in a directory other than the root
directory? the directory it was intended to be placed (i.e. the DOS
subdirectory)? Enter the following line in the config.sys file:
shell=c:\dos\command.com c:\dos
The config line shown above assumes that you have a hard disk and that
command.com resides in a subdirectory called DOS. You could of course
place it anywhere you like, so long as you include the path and follow
the statement with the path again. For example, if you booted from a
floppy and had placed command.com in a:\util\msdos, you would include
the following line in the config.sys file:
shell=a:\util\msdos\command.com a:\util\msdos
Naturally, you may place any of the parameters mentioned above after
this statement. For example, if you booted from a hard disk and your
only copy of command.com was in the subdirectory MSDOS and you wanted
to expand your environment space to 2500 bytes, you would change the
line to read:
shell=c:\msdos\command.com c:\msdos /e:2500
Even though you may decide to employ a shell statement as above, you
can still improve things. You could for example, pl